/*
 * Copyright Hundsun Technologies Inc. All Rights Reserved.
 */

package contract

import (
	"github.com/golang/protobuf/proto"
	ecom "hundsun.com/hsl/hschain/executor/common"
	"hundsun.com/hsl/hschain/protos/execute"
)

// Contract 合约接口,所有合约都需要实现该接口,参考nativetoken
// note: 交易扣费由每个执行器内部完成
type Contract interface {
	Init()                                                                                                // 外部初始化某些大资源
	Run(ctx *ecom.ExecContent, gtx *execute.GroupedTransaction) (*execute.GroupedTransaction, error)      // 执行交易
	Rollback(ctx *ecom.ExecContent, gtx *execute.GroupedTransaction) (*execute.GroupedTransaction, error) // 回滚交易
	Query(ctx *ecom.ExecContent, funcName string, param []byte) (proto.Message, error)                    // 查询功能
}
